#1、导包
import requests

#2、创建session对象，目的：自动管理cookie
session = requests.session()

#3、登录
url_login = "http://shop-xo.hctestedu.com"
form_dict = {"accounts":"xiaoxiami2024","pwd":"yb123456","type":"username"}
resp = session.post(url=url_login,data=form_dict)
print("登录响应码：{}".format(resp.status_code))

#4、提交订单
url_order = "http://shop-xo.hctestedu.com/index.php?s=/index/buy/add.html"
form_dict = {"goods_id":"11","buy_type":"goods","stock":"1","spec":"[{&quot;type&quot;:&quot;尺码&quot;,&quot;value&quot;:&quot;XL&quot;}]"
    ,"ids":"","address_id":"14956","payment_id":"4","user_note":"","site_model":"0"}
resp = session.post(url=url_order,data=form_dict)
print("提交订单响应码：{}".format(resp.status_code))
print("提交订单响应体：{}".format(resp.text))

#5、关闭session对象
session.close()